package com.zs.user.Listen;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @projectName: hmall-parent
 * @package: com.zs.user.Listen
 * @className: OrderListener
 * @author: zs
 * @description: TODO
 * @date: 2023/5/12 22:13
 * @version: 1.0
 */
@Component
public class OrderListener {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "order.queue"),
            exchange = @Exchange(name = "itcast.order", type = ExchangeTypes.TOPIC),
            key = "#"
    ))
    public void listenOrderDetail(Map map){
        Object orderId = map.get("orderId");
        Object userId = map.get("userId");
        Object name = map.get("name");
        System.out.println("恭喜您 ，您的订单: " +
                "{"+orderId+ "==> "+name +"}   {" + userId+"}  已经创建成功！！ ");
    }
}
